(function (lib, config) {
    var loadFunc = function () {
        var textAry = config.words.split('|'), bgcolorAry = config.bgcolor.split('|'), imglinkAry = config.imglink.split('|'), identifierAry = config.identifier.split('|');
        textAry[0] = textAry[0] || '昆明天伦医院微信';
        textAry[1] = textAry[1] || '您收到一条医生的微信消息';
        imglinkAry[0] = imglinkAry[0] || 'http://3g.9941120.com/swt/img/wxIcon.png';
        identifierAry[0] = identifierAry[0] || '';
        bgcolorAry[0] = bgcolorAry[0] || '#000';
        var sHTML = [
            '<style type="text/css">',/*left:0; top: 0*/
            '.topTips { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: fixed;'+lib.util.getPosStyle(config)+' ; width: 100%; z-index: 100000;-webkit-perspective: 600px; perspective: 600px;visibility:hidden;}',
            '.tipsInner {font-family: "Microsoft YaHei"; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); -webkit-transform-origin: 0px 0px; transform-origin: 0px 0px; -webkit-transform: rotateX(90deg); transform: rotateX(90deg); opacity: 0; }',
            '.tipsInner a { text-decoration:none;display: block; background: ' + bgcolorAry[0] + ';opacity:0.8;}',
            '.tipsInner dl { margin:0; padding: 10px;height: auto;overflow: hidden; position: relative;padding-left: 60px;}',
            '.tipsInner dl dt{width: 43px;height: 43px;background: url(' + imglinkAry[0] + ') no-repeat;position: absolute; left: 8px; top: 50%; margin-top: -21px;}',
            '.tipsInner dl dd{position: relative;height: auto;}',
            '.tipsInner dl dd p{line-height: 22px;font-size: 12px;color: #898a8a;font-family: "Microsoft YaHei";}',
            '.tipsInner dl dd p span{font-size: 14px;color: #ffffff;}',
            '.tipsInner dl dd b{color: #898a8a;font-size: 12px;width: 28px;text-align: center;line-height: 22px;position: absolute;top: 50%; margin-top: -21px;right: 8px;font-weight: normal;font-family: "Microsoft YaHei";}',
            '.tipsInner dl dd b i{display: block;width: 18px;height: 18px;background: url(' + imglinkAry[0] + ') no-repeat -86px -6px;margin: 0 auto;}',
            '.showTip { visibility:visible; }',
            '.showTip .tipsInner { -webkit-transform-origin: 0px 0px; transform-origin: 0px 0px; -webkit-transform: rotateX(0deg); transform: rotateX(0deg); opacity: 1; }',
            '.hideTip { visibility:hidden; }',
            '.hideTip .tipsInner { -webkit-transform-origin: 0px 100%; transform-origin: 0px 100%; -webkit-transform: rotateX(-90deg); transform: rotateX(-90deg); opacity: 0; }',
            '</style>',
            '<div class="topTips" id="toptips">',
            '   <div class="tipsInner">',
            '       <a href="javascript:void(0)" onclick="openZoosUrl(\'' + identifierAry[0] + '\');" class="JS-SWT-LINK">',
            '         <dl>',
            '           <dt></dt>',
            '           <dd><p><span>' + textAry[0] + '</span><br />' + textAry[1] + '</p><b>刚刚<i></i></b></dd>',
            '         </dl>',
            '       </a>',
            '   </div>',
            '</div>'].join('\r\n');
        var o = document.createElement('div');
        o.innerHTML = sHTML;
        while (o.firstElementChild) {
            document.body.appendChild(o.firstElementChild);
        };
        T = { hasClass: function (d, a) { var c = d.className.split(/\s+/); for (var b = 0; b < c.length; b++) { if (c[b] == a) { return true } } return false }, addClass: function (b, a) { if (!this.hasClass(b, a)) { b.className += " " + a } }, removeClass: function (d, a) { if (this.hasClass(d, a)) { var c = d.className.split(/\s+/); for (var b = 0; b < c.length; b++) { if (c[b] == a) { delete c[b] } } d.className = c.join(" ") } } };

        function Toptips(options) {
            this.init(options);
        };

        Toptips.prototype = {

            constructor: Toptips,

            init: function (options) {
                this.item = options.item;
                this.itemInner = options.item.children[0];
                this.loop = typeof options.loop == "undefined" ? true : options.loop;
                this.showTime = typeof options.showTime == "undefined" ? config.firsttime * 1000 : options.showTime;
                this.hideTime = typeof options.hideTime == "undefined" ? config.relapsetime * 1000 : options.hideTime;
                this.showTimer = null;
                this.hideTimer = null;
                this.preTimer = null;
                this.item.style.WebkitTransition = this.item.style.transition = this.itemInner.style.WebkitTransition = this.itemInner.style.transition = "0.5s";
                var me = this;
                var initTimer = setTimeout(function () {
                    me.showTip();
                }, 1000);
            },

            showTip: function () {
                var me = this;
                T.addClass(me.item, "showTip");
                T.removeClass(me.item, "hideTip");

                clearTimeout(me.hideTimer);
                me.showTimer = setTimeout(function () {
                    me.hideTip();
                }, me.showTime);

            },

            hideTip: function () {
                var me = this;
                T.removeClass(me.item, "showTip");
                T.addClass(me.item, "hideTip");
                me.item.style.visibility = me.itemInner.style.visibility = "hidden";

                if (me.loop) {
                    clearTimeout(me.showTimer);

                    me.preTimer = setTimeout(function () {
                        me.item.style.visibility = me.itemInner.style.visibility = "visible";
                    }, me.hideTime - 100);

                    me.hideTimer = setTimeout(function () {
                        me.showTip();
                    }, me.hideTime);

                }
            },

        };

        setTimeout(function () {
            var toptip = document.getElementById("toptips");
            new Toptips({
                item: toptip,
                loop: true
            });
        }, 1000);
        return false;
        delete o;
    };
    lib.load(loadFunc);
})('{{lib}}', '{{config}}');